package com.aspose.cells;

import java.util.HashMap;

class zaed {
   private com.aspose.cells.b.a.b.zi a = null;
   private com.aspose.cells.b.a.b.zg b = null;
   private int c = 96;
   private HashMap d = new HashMap();
   private HashMap e = new HashMap();

   zaed(Workbook var1) {
      com.aspose.cells.b.a.b.za var2 = new com.aspose.cells.b.a.b.za(10, 10);
      this.a = com.aspose.cells.b.a.b.zi.a((com.aspose.cells.b.a.b.zj)var2);
      this.b = this.a(var1.getWorksheets().G());
      this.c = var1.getWorksheets().L();
   }

   int a(Style var1, String var2) throws Exception {
      Font var3 = null;
      if (var1 != null) {
         var3 = var1.q();
         if (var3 != null && var3.j() == 0) {
            var3 = null;
         }
      }

      return this.a(var3, var2);
   }

   int a(Font var1, String var2) throws Exception {
      if (var2 != null && var2.length() != 0) {
         zbpz var3 = new zbpz(var1, var2);
         Object var4 = this.d.get(var3);
         if (var4 != null) {
            return (Integer)var4;
         } else if (var1 != null) {
            return zatm.a(var2, var1, 1.0D, 0);
         } else {
            com.aspose.cells.b.a.b.zg var5 = this.b;
            if (var1 != null) {
               var5 = this.a(var1);
            }

            com.aspose.cells.b.a.b.ze[] var6 = new com.aspose.cells.b.a.b.ze[]{new com.aspose.cells.b.a.b.ze(0, var2.length())};
            com.aspose.cells.b.a.b.zv var7 = new com.aspose.cells.b.a.b.zv();
            var7.a(var6);
            com.aspose.cells.a.d.zfq var8 = com.aspose.cells.a.d.zfs.b(var5.g(), var5.k(), false);
            float var9 = var8.a(var2, var5.h());
            int var10 = zaff.a(this.c, (double)var9);
            return var10;
         }
      } else {
         return 0;
      }
   }

   int a(Style var1, String var2, int var3) throws Exception {
      Font var4 = null;
      if (var1 != null) {
         var4 = var1.q();
         if (var4 != null && var4.j() == 0) {
            var4 = null;
         }
      }

      return this.a(var4, var2, var3);
   }

   int a(Font var1, String var2, int var3, int var4) throws Exception {
      String var5 = var2.substring(0, 0 + var4);
      int var6 = this.a(var1, var5);
      int var7 = var3 - var6 - 4;
      return var7;
   }

   int a(Font var1, String var2, int var3) throws Exception {
      zbpz var4 = new zbpz(var1, var2, var3);
      Object var5 = this.e.get(var4);
      if (var5 != null) {
         return (Integer)var5;
      } else {
         int var7 = this.a(var1, var2);
         int var6;
         if (var7 < var3) {
            var6 = -1;
         } else if (var7 == var3) {
            var6 = 0;
         } else {
            int var8 = var2.length();
            float var9 = (float)var7 / (float)var8;
            if (var7 > 1600) {
               var9 = (float)this.a(var1, "A");
            }

            var6 = (int)((float)var3 / var9);
            if (var6 > var8) {
               var6 = var8;
            }

            int var10 = this.a(var1, var2, var3, var6);
            if ((float)Math.abs(var10) > var9) {
               if (var10 <= 0) {
                  while(var10 < 0) {
                     --var6;
                     var10 = this.a(var1, var2, var3, var6);
                  }
               } else {
                  while(var10 > 0) {
                     ++var6;
                     var10 = this.a(var1, var2, var3, var6);
                  }

                  if (var10 <= 0) {
                     --var6;
                  }
               }
            }
         }

         this.e.put(var4, var6);
         return var6;
      }
   }

   private com.aspose.cells.b.a.b.zg a(Font var1) {
      String var2 = "Arial";
      int var3 = 10;
      int var4 = 0;
      if (var1 != null) {
         var2 = var1.getName();
         var3 = var1.getSize();
         if (var1.isBold()) {
            var4 |= 1;
         }

         if (var1.isItalic()) {
            var4 |= 2;
         }

         if (var1.isStrikeout()) {
            var4 |= 8;
         }

         if (var1.getUnderline() != 0) {
            var4 |= 4;
         }
      }

      com.aspose.cells.b.a.b.zg var5 = new com.aspose.cells.b.a.b.zg(var2, (float)var3, var4, 3);
      return var5;
   }

   int a(double var1) {
      double var3 = var1 * (double)this.c / 72.0D;
      return (int)var3;
   }

   double a(int var1) {
      return (double)var1 * 72.0D / (double)this.c;
   }
}
